home *** CD-ROM | disk | FTP | other *** search
/ Garbo / Garbo.cdr / mac / progrmng / exmpldrw.sit / For THINK Pascal 3.0 / READ ME < prev   
Encoding:
Text File  |  1990-07-02  |  4.0 KB  |  59 lines  |  [TEXT/ttxt]

  1. Converting ExampleDraw for use with THINK Pascal 3.0
  2. Larry Rosenstein
  3. 7/1/90
  4.  
  5. The ExampleDraw program, as it comes with ╥Programming with MacApp╙ won╒t work with THINK Pascal 3.0.  (If you are interested, the reasons are given below.)  The files in this folder will convert the sources to make ExampleDraw compatible with THINK Pascal 3.0.
  6.  
  7. To convert ExampleDraw you need a copy of the sources from the original diskette.  You also need to put the 'THINK Diffs' and 'SpecialUnits' folders in the folder that will contain the converted sources.  (The conversion process will not change the original sources.)
  8.  
  9. To convert ExampleDraw, double click the ExampleDraw.Script file.  Select the folder containing the original sources and the folder to contain the modified sources.  After you have converted the source, you will need to add the ExampleDraw files to a project.  Make a copy of the appropriate MacApp Seed Project.  Add the ExampleDraw files to the project in the following order:
  10.  
  11. UStream.p
  12. UQuickDrawPattern.p
  13. UShape.p
  14. UConcreteShapes.p
  15. UShapeList.p
  16. UShapeFilters.p
  17. UShapeViewHelper.p
  18. UShapeDocument.p
  19. UShapeCommands.p
  20. UShapePaletteView.p
  21. UShapeView.p
  22. UShapeCommandImpl.p
  23. UShapeViewHelperImpl.p
  24. UExampleDraw.p
  25. MExampleDraw.p
  26.  
  27. UShapeCommandImpl.p and UShapeViewHelperImpl.p are 2 new units created by the conversion script.  They are needed to resolve a mutual dependency between some of the units.
  28.  
  29. You will also need to create the resource file for ExampleDraw.  (This is left as an exercise for the reader. )  Once you have that, you should be able to compile and run ExampleDraw.
  30.  
  31. Let me know if you have any comments or problems.
  32.  
  33. Larry Rosenstein
  34. 182 Muir Ave
  35. Santa Clara, CA 95051
  36.  
  37. Internet:  lsr@Apple.COM
  38. AppleLink: ROSENSTEIN1
  39.  
  40.  
  41. Why ExampleDraw doesn╒t work as is:
  42.  
  43. There are 3 reasons why ExampleDraw needs any conversion at all.  You might find this information useful as you try to convert some of your MPW Pascal programs to THINK Pascal.
  44.  
  45. (1) THINK Pascal does additional type checking of VAR parameters that are objects.  Specifically, if a routine has a parameter such as VAR obj: TObject, then THINK Pascal will not let you pass a subclass of TObject to that routine.  The parameter must be a TObject.
  46.  
  47. This occured in 3 places in the ExampleDraw sources.  In each place, the solution was to declare a temporary variable of the proper type, pass it to the routine, and then coerce the temporary to the desired type.  This is only a quick fix; the real solution is to change the affected procedures to functions that return a value, rather than returning the value using a VAR parameter.
  48.  
  49. (2) A couple of the ExampleDraw units depend on one another.  In some cases (such as ExampleDraw), MPW Pascal allows this.  THINK Pascal, however requires that each unit appearing in USES statement of unit A precede unit A in the project list (in build order). 
  50.  
  51. Fortunately, THINK Pascal allows a unit to define classes and methods that are implemented in another unit.  In the case of ExampleDraw, I had to divide the UShapeViewHelper and UShapeCommands units into 2 units.  The converted files UShapeViewHelper.p and UShapeCommands.p do not contain and implementation.  Their purpose is to define the interfaces to the units so that other units can be compiled.
  52.  
  53. The implementations are in the files UShapeViewHelperImpl.p and UShapeCommandsImpl.p, respectively.  These units do not define any interface, but each uses the appropriate interface file.  Breaking up the units in this way eliminates the mutual dependencies.  The files in the SpecialUnits folder are used to generate the implementation units.
  54.  
  55. (3) THINK Pascal (apparently) does not allow a declared array bounds to be a constant expression.  This occurs twice in UExampleDraw.inc1.p.  To fix the problem, I created new constants (whose values can be expressions) and used them in declaring the arrays.
  56.  
  57. In addition, there is a bug in the TCountingStream class, which the converter fixes.  The fPosition field wasn't initialized in the ICountingStream method, and there were no methods to set or get fPosition and fSize fields.
  58.  
  59.